package com.eversec.view.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import com.eversec.view.dialog.ConfirueDialog;

/**
 * 
 * @author Administrator
 *
 */
public class IdcMenuBar extends JMenuBar {

	private static final long serialVersionUID = 1412224702724671832L;
	
	//文件菜单项
	private JMenuItem exitItem;
	private JMenuItem configureItem;
	private JMenuItem aboutItem;

	public IdcMenuBar() {
		initMenuItem();
		initAction();
	}

	/**
	 * 构建菜单
	 */
	private void initMenuItem() {
		JMenu fileMenu = new JMenu("文件");
		JMenu toolMenu = new JMenu("工具");
		JMenu helpMenu = new JMenu("帮助");
		
		exitItem = new JMenuItem("退出");
		fileMenu.add(exitItem);
		
		configureItem = new JMenuItem("配置");
		toolMenu.add(configureItem);
		
		aboutItem = new JMenuItem("关于");
		helpMenu.add(aboutItem);
		
		add(fileMenu);
		add(toolMenu);
		add(helpMenu);
	}

	/**
	 * 菜单项响应事件
	 */
	private void initAction() {
		exitItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		configureItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new ConfirueDialog();
			}
		});
		aboutItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
			}
		});
	}
	
	

}
